import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
    state: {
		userInfo:null,
		token: uni.getStorageSync("token")
	},
    mutations: {
		login(state,data){
			uni.setStorageSync("token",data.token);
			state.userInfo = data.userInfo;
			state.token = data.token;
		},
		logout(state){
			state.userInfo = null;
			state.token = null;
			uni.removeStorageSync("token");
		}
	},
    getters:{
		hasLogin(state){
			return state.userInfo && state.token;
		}
	}
})

export default store